#include <myhead.h>
int main(int argc, const char *argv[])
{
	//1、
	int C=socket(AF_INET,SOCK_DGRAM,0);
	if(C==-1){perror("套接字创建失败\n");return -1;}
	//2、
	struct sockaddr_in addr={0};
	addr.sin_family=AF_INET;
	addr.sin_port=htons(12345);
	addr.sin_addr.s_addr=inet_addr("");
	if(bind(C,(struct sockaddr*)&addr,sizeof(addr))==-1){perror("服务器绑定失败");return -1;}
	/*
	//3、设置允许广播
	int m=1;
	setsockopt(S,SOL_SOCKET,SO_BROADCAST,&m,4);

	struct sockaddr_in addt={0};
	addt.sin_fanily=AF_INET;
	addt.sin_port=htons(12345);
	addt.sin_addr.s_addr=inet_addr("255.255.255.255");
	*/
	while(1)
	{
		char buf[128]={0};
		//sendto(S,buf,strlen(buf),0,(struct sockaddr*)&addt,sizeof(addt));
		//sleep(1);
		recv(C,buf,128,0);
		printf("接收到广播消息为%s\n",buf);
	}

	return 0;
}
